package com.gdupt.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gdupt.entity.vo.ResponseData;
import com.gdupt.entity.vo.StatisticalReportVo;
import com.gdupt.service.IStatisticalReport;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/Statistical-Report")
public class StatisticalReportController {
    @Autowired
    private   IStatisticalReport iStatisticalReport;

    @RequestMapping("/CustomerContribution")
    public ResponseData searchCustomerContribution(Page page,@Param("search") String search){
        List<StatisticalReportVo> list = iStatisticalReport.searchCustomerContribution(page,search);
        return  ResponseData.okData(page.getTotal(),list);
    }

    @RequestMapping("/CustomerComposition/{search}")
    public ResponseData searchCustomerComposition(Page page, @PathVariable("search") Integer id){
        System.out.println(id);
        List<StatisticalReportVo> list=new ArrayList<StatisticalReportVo>();
        if (id==-1){
             list= iStatisticalReport.searchCustomerComposition(page);
        }else if(id==0){
             list= iStatisticalReport.searchCustomerComposition1(page);
        }else if (id==1)
        {
             list= iStatisticalReport.searchCustomerComposition2(page);

        }
        return   ResponseData.okData(page.getTotal(),list);
    }

//    @RequestMapping("/CustomerComposition1")
//    public ResponseData searchCustomerComposition1(Page page){
//        List<StatisticalReportVo> list= iStatisticalReport.searchCustomerComposition1(page);
//        System.out.println(list);
//        return   ResponseData.okData(page.getTotal(),list);
//    }
//    @RequestMapping("/CustomerComposition2")
//    public ResponseData searchCustomerComposition2(Page page){
//        List<StatisticalReportVo> list= iStatisticalReport.searchCustomerComposition2(page);
//        System.out.println(list);
//        return   ResponseData.okData(page.getTotal(),list);
//    }

    @RequestMapping("/CustomerService")
    public ResponseData searchCustomerService(Page page){
        List<StatisticalReportVo> list = iStatisticalReport.searchCustomerService(page);
        return  ResponseData.okData(page.getTotal(),list);
    }

}
